package org.zcq100.GUI.test1;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;

import javax.swing.*;

public class MyFrame extends JFrame {
	public MyFrame() {
		setSize(200, 200);
		setDefaultCloseOperation(3);
		btn1 = new JButton("Click");
		btn1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				//new MyDialg(txt1.getText());
				JLabel lbl = new JLabel(txt1.getText());
				new MyDialg().setLabel(lbl);
			}
		});
		timeLbl=new JLabel();
		
		new Thread(new Runnable() {
			public void run() {
				while (true) {
					try {
						String time = new SimpleDateFormat("hh:mm:ss")
								.format(new java.util.Date());
						timeLbl.setText(time);
						Thread.sleep(1000);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}).start();

		txt1 = new JTextField(20);
		add(btn1);
		add(txt1);
		add(timeLbl);
		setLayout(new FlowLayout());
		pack();
		setVisible(true);
	}

	public static void main(String[] args) {
		MyFrame f = new MyFrame();

	}

	private JTextField txt1;
	private JButton btn1;
	private JLabel timeLbl;
}
